//
//  baseToast.m
//  baseVC
//
//  Created by 陶磊 on 2019/12/16.
//  Copyright © 2019 QHT. All rights reserved.
//

#import "baseToast.h"
#import "UIView+Toast.h"
#import <MBProgressHUD.h>

@implementation baseToast


// toast
+ (void)make:(UIView *)view string:(NSString *)str
{
    if (!str.length) {
        return;
    }
    [self make:view string:str duration:1.5];
}

+ (void)make:(UIView *)view string:(NSString *)str duration:(CGFloat)time
{
    if (!str.length) {
        return;
    }
    [view makeToast:str duration:time position:CSToastPositionCenter];
}

+ (void)makeOnTheWindow:(NSString *)str
{
    if (!str.length) {
        return;
    }
    [self make:KEYWINDOW string:str];
}

// activity
+ (void)makeActivity:(UIView *)view
{
    dispatch_async(dispatch_get_main_queue(), ^{
        [MBProgressHUD showHUDAddedTo:view animated:YES];
    });
}

+ (void)hideActivity:(UIView *)view
{
    dispatch_async(dispatch_get_main_queue(), ^{
        [MBProgressHUD hideHUDForView:view animated:YES];
    });
}

+ (void)makeActivityOnTheWindow
{
    dispatch_async(dispatch_get_main_queue(), ^{
        [self makeActivity:KEYWINDOW];
    });
}

+ (void)hideActivityOnTheWindow
{
    dispatch_async(dispatch_get_main_queue(), ^{
        [self hideActivity:KEYWINDOW];
    });
}




@end
